/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.List;
import java.util.stream.Stream;

/**
 * <p>Project: javaseapp - IntSteam2
 * <p>Powered by webrx On 2021-08-20 18:16:34
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class IntSteam2 {
    public static void main(String[] args) {
        //IntStream is = IntStream.range(0, 2);
        //IntStream is2 = IntStream.iterate(0, (e) -> e + 1).limit(5);
        //is2.forEach(System.out::println); // 0 1 2 3 4
        //IntStream is3 = IntStream.iterate(0, e -> true, e -> e + 1).limit(3);
        //is3.forEach(System.out::println);

        //java Stream Fibonacci series
        var s = Stream.iterate(List.of(0, 1), i -> List.of(i.get(1), i.get(0) + i.get(1))).limit(15);
        s.forEach(e -> {
            System.out.printf("%d ", e.get(0));
        });

    }
}
